package com.legstar.talend.xsd2xml;

import com.thoughtworks.xstream.annotations.XStreamAlias;
import com.thoughtworks.xstream.annotations.XStreamAsAttribute;

/**
 * Talend XML schema column.
 * 
 * <column comment="" default="" key="false" label="ComNumber" length="-1"
 * nullable="true" originalDbColumnName="ComNumber" pattern="" precision="-1"
 * talendType="id_Long" type=""/>
 * 
 * */
@XStreamAlias("column")
public class TosSchemaColumn implements Cloneable {

    @XStreamAsAttribute
    private String comment = "";

    @XStreamAsAttribute
    @XStreamAlias("default")
    private String _default = "";

    @XStreamAsAttribute
    private String key;

    @XStreamAsAttribute
    private String label;

    @XStreamAsAttribute
    private int length = -1;

    @XStreamAsAttribute
    private boolean nullable;

    @XStreamAsAttribute
    private String originalDbColumnName;

    @XStreamAsAttribute
    private String pattern = "";

    @XStreamAsAttribute
    private int precision = -1;

    @XStreamAsAttribute
    private String talendType;

    @XStreamAsAttribute
    private String type = "";

    /** {@inheritDoc} */
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("[");
        sb.append("comment" + ":'" + comment + "'");
        sb.append(",");
        sb.append("default" + ":'" + _default + "'");
        sb.append(",");
        sb.append("key" + ":'" + key + "'");
        sb.append(",");
        sb.append("label" + ":'" + label + "'");
        sb.append(",");
        sb.append("length" + ":'" + length + "'");
        sb.append(",");
        sb.append("nullable" + ":'" + nullable + "'");
        sb.append(",");
        sb.append("originalDbColumnName" + ":'" + originalDbColumnName + "'");
        sb.append(",");
        sb.append("pattern" + ":'" + pattern + "'");
        sb.append(",");
        sb.append("precision" + ":'" + precision + "'");
        sb.append(",");
        sb.append("talendType" + ":'" + talendType + "'");
        sb.append(",");
        sb.append("type" + ":'" + type + "'");
        sb.append(",");
        sb.append("]");
        return sb.toString();
    }

    /**
     * @return the comment
     */
    public String getComment() {
        return comment;
    }

    /**
     * @param comment the comment to set
     */
    public void setComment(String comment) {
        this.comment = comment;
    }

    /**
     * @return the _default
     */
    public String getDefault() {
        return _default;
    }

    /**
     * @param _default the _default to set
     */
    public void setDefault(String _default) {
        this._default = _default;
    }

    /**
     * @return the key
     */
    public String getKey() {
        return key;
    }

    /**
     * @param key the key to set
     */
    public void setKey(String key) {
        this.key = key;
    }

    /**
     * @return the label
     */
    public String getLabel() {
        return label;
    }

    /**
     * @param label the label to set
     */
    public void setLabel(String label) {
        this.label = label;
    }

    /**
     * @return the length
     */
    public int getLength() {
        return length;
    }

    /**
     * @param length the length to set
     */
    public void setLength(int length) {
        this.length = length;
    }

    /**
     * @return the nullable
     */
    public boolean isNullable() {
        return nullable;
    }

    /**
     * @param nullable the nullable to set
     */
    public void setNullable(boolean nullable) {
        this.nullable = nullable;
    }

    /**
     * @return the originalDbColumnName
     */
    public String getOriginalDbColumnName() {
        return originalDbColumnName;
    }

    /**
     * @param originalDbColumnName the originalDbColumnName to set
     */
    public void setOriginalDbColumnName(String originalDbColumnName) {
        this.originalDbColumnName = originalDbColumnName;
    }

    /**
     * @return the pattern
     */
    public String getPattern() {
        return pattern;
    }

    /**
     * @param pattern the pattern to set
     */
    public void setPattern(String pattern) {
        this.pattern = pattern;
    }

    /**
     * @return the precision
     */
    public int getPrecision() {
        return precision;
    }

    /**
     * @param precision the precision to set
     */
    public void setPrecision(int precision) {
        this.precision = precision;
    }

    /**
     * @return the talendType
     */
    public String getTalendType() {
        return talendType;
    }

    /**
     * @param talendType the talendType to set
     */
    public void setTalendType(String talendType) {
        this.talendType = talendType;
    }

    /**
     * @return the type
     */
    public String getType() {
        return type;
    }

    /**
     * @param type the type to set
     */
    public void setType(String type) {
        this.type = type;
    }

    @Override
    protected TosSchemaColumn clone() {
        try {
            return (TosSchemaColumn) super.clone();
        } catch (CloneNotSupportedException e) {
            return null;
        }
    }

}
